<extend name="Base/common"/>
<block name="left"></block>
<block name="body">
<div class="proDelBox" style="background: #FFF;">
	<p class="proRegisterpde proRegisterborderbottom proRegisterborderbottom-css3" style="padding-left: 20px;">为了您的账号安全，请先进行身份验证</p>
	<p class="proRegisterpde proRegisterborderbottom proRegisterborderbottom-css3" style="padding-left: 20px;">已绑定手机号:{$mobile}</p>
	<p class="proRegisterpde proRegisterborderbottom  reg_code clearfix" >
		<input type="text" name="code" id="code" placeholder="验证码" style="margin-left: 20px;width:150px;">
		<input type="submit" class="btn click" value="获取验证码" id="GetCode" >
	</p>
	<p class="proRegisterpde proRegisterborderbottom  reg_pwd clearfix reg_password">
		<input  placeholder="密码" name="password" id="password" value="" type="password" style="margin-left: 20px;">
	</p>
	<p class="proRegisterpde proRegisterborderbottom proRegisterborderbottom-css3 reg_repwd clearfix reg_password">
		<input  placeholder="确认密码" name="repassword" id="repassword" value="" type="password" style="margin-left: 20px;">
	</p>
	<span class="msg"></span>
	<div style="padding: 0px 20px;"><input type="button" value="确认重置" class="reg_btn"></div>
</div>
<script type="text/javascript">	

$(document).ready(function(){
        // 获取验证码
        $("#GetCode").click(function(){ 
                var mobile="{$mobile}";
                var reg=/^1[3|4|5|7|8]\d{9}$/;
                if (reg.exec(mobile)==null) {
                  $('.msg').html('手机号不匹配或不为空');
                    return false;
                }else{
                    $('.msg').html('');
                }
                var url="{:U('User/send_verify')}";
                $.post(url,{mobile:mobile},function(data){
                    if(data.status){
                        setInt();
                    }else{       
                        $(".msg").html(data.msg);
                    }
                },'json')                                   
                setInt();
            })
            var count=60;
            var curCount;
            var objTime;
            function setTime(){ 
                if (curCount==0) {
                    clearInterval(objTime);
                    $('#GetCode').removeAttr('disabled');
                    $('#GetCode').css('background','#cc2a1e');
                    $('#GetCode').val('重发验证码');                    
                }else{  
                    curCount--; 
                    $('#GetCode').val(curCount + "秒后重发")
                }
            }

            function setInt() {
                curCount=count;             
                $('#GetCode').attr('disabled','true');
                $('#GetCode').css('background','#b1b1b1');
                $('#GetCode').val(curCount + "秒后重发")                                                
                objTime=setInterval(setTime,1000);
            }

    })
	$('.reg_btn').click(function(){
		var mobile="{$mobile}";
		var password=$('#password').val();
		var repassword=$('#repassword').val();
		var code=$('#code').val();
		var url="{:U('User/find_pwd')}";
		var reg=/^1[3|4|5|7|8]\d{9}$/;
		if(reg.exec(mobile)==null) {
             $('.msg').css('display','block');
             $('.msg').html('手机号不匹配或不为空');
             return false;
        }
        if(password==''){
            $('.msg').css('display','block');
        	$('.msg').html('密码不能为空');
            return false;
        }
        if(repassword==''){
            $('.msg').css('display','block');
        	$('.msg').html('确认密码不能为空');
            return false;
        }
        if(password!=repassword){
            $('.msg').css('display','block');
        	$('.msg').html('密码不相同');
            return false;
        }
        if(code==''){
            $('.msg').css('display','block');
        	$('.msg').html('验证码不能为空');
            return false;
        }
		$.post(url,
			{
				phone:mobile,
				password:password,
				repassword:repassword,
				code:code,
			},function(data){
          		if(data.status){
          			$('.msg').css('display','block');
          			$('.msg').html(data.msg);
          			setTimeout(link_url,2000);	
          		}else{
          			$('.msg').css('display','block');
          			$('.msg').html(data.msg);
          		}
        },'json')   
        
		
	})
	
	
	
	function link_url(){
		var url_href="{:U('Index/index')}";;
		window.location.href=url_href;		
	}
</script>
    <include file="Public/footer"/>
</block>